<template>
    <div class="bc-loading" :style="{
        'position': position,
        'zIndex': zIndex}">
        <div class="bc-loading__curtain" :style="{
            'backgroundColor': curtainType
        }"></div>
        <div class="bc-loading__icon" :style="{'color':iconColor}">
            <bc-icon :name="iconName" :size="iconSize"></bc-icon>
            <p class="bc-loading__text" :style="{'fontSize': textSize+'px'}">{{context}}</p>
        </div>
    </div>
</template>

<script>
import BcIcon from '@/components/icon/src/icon.vue'

export default {
    components: {BcIcon},
    name: 'BcLoading',
    props: {
        position: {
            type: String,
            default: 'fixed'
        },
        zIndex: {
            type: Number,
            default: 200
        },
        context: {
            type: String,
            default: '加载中...'
        },
        iconName: {
            type: String,
            default: 'bc-loading4'
        },
        type: {
            type: String,
            default: 'dark'
        },
        iconColor: {
            type: String,
            default: '#2d8cf0'
        },
        iconSize: {
            type: [Number, String],
            default: 25
        },
        textSize: {
            type: Number,
            default: 16
        }
    },
    computed: {
        curtainType() {
            if(this.type === 'light') return 'rgba(255,255,255,.7)';
            else return 'rgba(0,0,0,.7)';
        }
    }
}
</script>

<style scoped>
.bc-loading {
    width: 100%;
    height: 100%;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    margin: auto;
}
.bc-loading>.bc-loading__curtain {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    margin: auto;
}
.bc-loading>.bc-loading__icon {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    margin: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    z-index: 10;
}
.bc-loading>.bc-loading__icon>.bc-loading__text {
    margin-top: 5px;
}
</style>